package parser;

import lexer.Token;

/**
 * An exception class which is used throughout the Parsing stage Outputs some
 * basic error diagnostics.
 * 
 * @author Adam
 * 
 */
public class LogoParseException extends Exception {
	private static final long serialVersionUID = 1L;
	Token errorToken;

	public LogoParseException(Token token, String message) {
		super(generateMessage(token, message));

		errorToken = token;
	}

	public LogoParseException(String message) {
		super(message);
	}

	private static String generateMessage(Token token, String message) {
		if (token == null) {
			return message;
		} else {
			return "Error at line " + token.getFileLine() + " col " + token.getFileCol() + ": " + message;
		}
	}
}
